import axios from 'axios'

// 创建axios实例
const apiClient = axios.create({
  baseURL: '/api', // 基础URL，根据实际情况调整
  withCredentials: true, // 允许携带cookie
  headers: {
    'Content-Type': 'application/json'
  }
})

// 定义考试学生VO接口
export interface ExamStudentVo {
  examId: number
  courseName: string
  examName: string
  startTime: string
  endTime: string
  totalScore: number
  examDuration: number | null
  description: string
  status: number
}

// 定义响应数据接口
export interface ApiResponse<T> {
  code: number
  msg: string
  data: T
  dataCount: number
}

// 获取学生考试列表
export const getStudentExams = async (): Promise<ApiResponse<ExamStudentVo[]>> => {
  try {
    const response = await apiClient.get<ApiResponse<ExamStudentVo[]>>('/exam/query/studentId')
    return response.data
  } catch (error) {
    throw new Error('获取考试列表失败')
  }
}